<?php 
    include "database.php";
    
    //Za delovanje seje na vseh nivojih
    session_set_cookie_params(0,"/");
    session_start();
    
    $username = $_SESSION['username'];
    if(!isset($_SESSION['username'])) {
        header("Location: login.php");
    }
?>

<!DOCTYPE html>

<html>
	<head>
	    <meta charset="utf-8">
		
		<!-- Font weight: light (300) & semibold (600) -->
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:600,300' rel='stylesheet' type='text/css'>
		<link rel="stylesheet" href="css/default.css"/>
		
		<title>Scrum | Edit Profile</title>		
	</head>
	
	<body>
	
		<span id="username"><?php echo $username  ?></span>
		<span id="separator">|</span>
		<a href="edit_profile.php"><span id="role" class="active">edit</span></a>
		
		<h1>Scrum</h1>
		
		<menu>
			<li><a href="control_panel.php">control<span>Panel</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="project_wall.php">project<span>Wall</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="product_backlog.php">product<span>Backlog</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="sprint_backlog.php">sprint<span>Backlog</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="my_tasks.php">my<span>Tasks</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="progress_report.php">progress<span>Reports</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="./php/logout.php">logout</a></li>
		</menu>
		
		<section>
		
			<h2>edit<span>Profile</span></h2>
			
			<div class="bracket">
				<p class="alert_string"><?php showMessage(); ?></p>
				<!-- Ce ni obvestila se doda razred hidden: class="alert_string hidden" -->
				
				<form id="edit_profile_form" method="post">
					<?php 
					
					$query = "SELECT * FROM user WHERE username LIKE '$username';";
					$queryResult = executeQuery($query);
					$row = mysql_fetch_array($queryResult);
					echo "<input type=\"hidden\" name=\"id\" value=\"$row[0]\"/> <br/>";			
					echo "<input type=\"text\" name=\"username\" placeholder=\"$row[1]\" value=\"$row[1]\" required=\"required\" /> <br/>"; 
					echo "<input type=\"text\" name=\"first_name\" placeholder=\"$row[2]\" value=\"$row[2]\" required=\"required\" /> <br/>";
					echo "<input type=\"text\" name=\"last_name\" placeholder=\"$row[3]\" value=\"$row[3]\" required=\"required\" /> <br/>";
					echo "<input type=\"email\" name=\"email\" placeholder=\"e-mail\" value=\"$row[4]\" required=\"required\" /> <br/>";
					echo "<input type=\"password\" name=\"password\" placeholder=\"password\" required=\"required\" />";
					echo "<input type=\"password\" name=\"password_confirm\" placeholder=\"confirm password\" required=\"required\" /> <br/>";
					
					?>
					
					<input id="edit_profile_submit" type="submit" name="submit" value="submit" formaction="./php/editProfile.php" />
				</form>
			</div>
		
		</section>
		
	</body>
</html>